package thin4ca

class Domain(repository: EntityRepository) {

  def updateEntities(entities: List[EntityDef]) = {
    entities.foreach(
      repository.create(_)
    )
  }

  def add(id: String, entity: Entity) = {
    entity.id = id
    repository add entity
  } 

  def find(typez: String, id: String): Entity = {
    repository.find(typez, id);
  }
  
  def findAttr(typez: String, id: String, attr: String): Any = {
    println("findAttr + attr " + attr)
    val entity = repository.find(typez, id)
    println("findAttr + entity " + entity)
    entity.get(attr)
  }
}
